package com.poh.service.impl;

import com.poh.mapper.SingInMapper;
import com.poh.pojo.SingIn;
import com.poh.service.SingInService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Service
public class SingInServiceImpl implements SingInService {
    @Autowired
    SingInMapper singInMapper;
    @Override
    public int addSingIn(SingIn singIn) {
        LocalDate localDate = LocalDate.now();
        LocalTime localTime = LocalTime.now();
        singIn.setAddTime(localDate.format(DateTimeFormatter.ISO_DATE) + " " + localTime);
        return singInMapper.addSingIn(singIn);
    }

    @Override
    public int deleteSingIn(String sId) {
        return singInMapper.deleteSingIn(sId);
    }

    @Override
    public List<SingIn> querySingInByCourseId(int courseId) {
        return singInMapper.querySingInByCourseId(courseId);
    }

    @Override
    public int updateSingInStatus(int singInStatus, String sid) {
        LocalDate localDate = LocalDate.now();
        LocalTime localTime = LocalTime.now();

        return singInMapper.updateSingInStatus(singInStatus, sid, localDate.format(DateTimeFormatter.ISO_DATE) + " " + localTime);
    }

    @Override
    public int updateSUSingInStatus(String sId, int singInStatus) {
        return singInMapper.updateSUSingInStatus(sId, singInStatus);
    }
    @Override
    public String queryCodeBySid(String sId) {
        return singInMapper.queryCodeBySid(sId);
    }

    @Override
    public SingIn querySingInBySid(String sId) {
        return singInMapper.querySingInBySid(sId);
    }
}
